<%@ include file="IsStudent.jsp"%>
<%@ page import="java.io.*, java.text.*, java.util.Date, java.sql.*, javax.servlet.*, javax.servlet.http.*, java.util.*,database.*" %>

<%!
public void check(String [] arr)
{
	for(int i=0;i<arr.length;i++)
	{
		while(arr[i] != null && arr[i].indexOf("\n") != -1)
		{
			arr[i] = arr[i].substring(0,arr[i].indexOf("\n")-1) + "<br/>" + arr[i].substring(arr[i].indexOf("\n")+1,arr[i].length());
		}
	}
}
%>

<%
try{
DBCon db = new DBCon();
	
		String pid = request.getParameter("pId");
		
		String [] proj = new String[10];
		
	
			
			ResultSet rs1 = null;
                        
			
			
			rs1 = db.getProject("where id ="+pid);
			
			if(rs1.next())
			{
				proj[0] = rs1.getString("Title");
				proj[1] = rs1.getString("description");
				proj[2] = rs1.getString("Project_Objectives");
				proj[3] = rs1.getString("Required_Background");
				proj[4] = rs1.getString("Tools_Needed");
				proj[5] = rs1.getString("Difficulty_Level");
				proj[6] = rs1.getString("Project_Type");
				proj[7] = rs1.getString("Project_Keywords");
				proj[8] = rs1.getString("Expected_Results");
				proj[9] = rs1.getString("Additional_Comments");
			}
			
			check(proj);

			out.println("<script type='text/javascript'>");
			out.println("var dproj = new Array();"); 
			out.println("dproj[0] = '"+ proj[0]+"'");
			out.println("dproj[1] = '"+ proj[1]+"'");
			out.println("dproj[2] = '"+ proj[2]+"'");
			out.println("dproj[3] = '"+ proj[3]+"'");
			out.println("dproj[4] = '"+ proj[4]+"'");
			out.println("dproj[5] = '"+ proj[5]+"'");
			out.println("dproj[6] = '"+ proj[6]+"'");
			out.println("dproj[7] = '"+ proj[7]+"'");
			out.println("dproj[8] = '"+ proj[8]+"'");
			out.println("dproj[9] = '"+ proj[9]+"'");
			out.println("</script>");
			
		
		
}
catch(Exception e)
{
    response.sendRedirect("../connectionFailed.jsp?"+e);
}
%>
<html>
<head>
<style>
.free {
	margin-right:0px;
	color: #406AFD;
	background-color: #d8e7fb;
	font-size: 8pt;
	font-weight: bold;
	text-align: center;
	border-bottom: dashed 1px #4f75a6;
	border-right: dashed 1px #d8e7fb;
	border-left: dashed 1px #d8e7fb;
	border-top: solid 1px #d8e7fb;
	cursor:pointer;
	width: 90px; 
	height: 35px;	
}

.choosen {
	margin-right:0px;
	color: white;
	background-color: #4f75a6;
	font-weight: bold;
	font-size: 8pt;
	border-bottom: none;
	border-left:  dashed 1px #4f75a6;
	border-top: dashed 1px #4f75a6;
	border-right:  dashed 1px #4f75a6;
	text-align:center;
	width: 90px; 
	height: 35px;
}

.tabsbody {
	font-size: 13pt;
	background-color: #4f75a6;
	border-bottom: dashed 1px #4f75a6;
	border-left:  dashed 1px #4f75a6;
	border-right:  dashed 1px #4f75a6;
}
.Btable {
	border-left:solid 1px black;
	border-right: solid 1px black;
	border-top:solid 1px black;
	border-bottom: solid 1px black;
}

.mainDiv{
	overflow: auto;
	}
#preview
{
	border-top: dashed 1px #4f75a6;
	border-bottom: dashed 1px #4f75a6;
	border-left:  dashed 1px #4f75a6;
	border-right:  dashed 1px #4f75a6;
}

</style>
</head>
<body onload="initial()">
<script>
/*	scrollbar-darkshadow-color: #d8e7fb;
	scrollbar-shadow-color: pink;*/
var previousType = "Description";
function initial()
{
	document.getElementById("preview").innerHTML = dproj[1];;
	document.getElementById("titleDiv").innerHTML = "<u>" +dproj[0] + "</u>";
	
	//document.body.scroll = "yes";
	
	
}

function show1(index,type)
{
	document.getElementById("preview").innerHTML = dproj[index];
	document.getElementById(previousType).className = "free";
	document.getElementById(type).className = "choosen";
	previousType = type;
	resizeImg();
	
}

function printProject()
{
	var out;
	
	out = "<center><input type='button' value='&nbsp;&nbsp;Print&nbsp;&nbsp;' onclick='window.print();'/></center>";	
	out += "<table  name ='printTable' class='Btable' height= '50%' width='99%' cellspacing='0' cellpadding='2' border='2' scrolling=yes>";
	out += "<tr><td style='width: 110px; background-color: #f0f0f0; font-size: 14pt' colspan='2'><b>Title:</b></td><td colspan='8'>"+dproj[0]+"</td></tr>";
	out += "<tr><td style='width: 110px; background-color: #f0f0f0; font-size: 14pt' colspan='2'><b>Description</b></td><td colspan='8'>"+dproj[1]+"</td></tr>";
	out += "<tr><td style='width: 110px; background-color: #f0f0f0; font-size: 14pt' colspan='2'><b>Project<br>Objectives</b></td><td colspan='8' >"+dproj[2]+"</td></tr>";
	out += "<tr><td style='width: 110px; background-color: #f0f0f0; font-size: 14pt' colspan='2'><b>Required<br>Background</b></td><td colspan='8' >"+dproj[3]+"</td></tr>";
	out += "<tr><td style='width: 110px; background-color: #f0f0f0; font-size: 14pt' colspan='2'><b>Tools<br>Needed</b></td><td colspan='8' >"+dproj[4]+"</td></tr>";
	out += "<tr><td style='width: 110px; background-color: #f0f0f0; font-size: 14pt' colspan='2'><b>Difficulty<br>Level</b></td><td colspan='8' >"+dproj[5]+"</td></tr>";
	out += "<tr><td style='width: 110px; background-color: #f0f0f0; font-size: 14pt' colspan='2'><b>Project<br>Type</b></td><td colspan='8' >"+dproj[6]+"</td></tr>";
	out += "<tr><td style='width: 110px; background-color: #f0f0f0; font-size: 14pt' colspan='2'><b>Project<br>Keywords</b></td><td colspan='8' >"+dproj[7]+"</td></tr>";
	out += "<tr><td style='width: 110px; background-color: #f0f0f0; font-size: 14pt' colspan='2'><b>Expected<br>Results</b></td><td colspan='8' >"+dproj[8]+"</td></tr>";
	out += "<tr><td style='width: 110px; background-color: #f0f0f0; font-size: 14pt' colspan='2'><b>Additional<br>Comments</b></td><td colspan='8' >"+dproj[9]+"</td></tr></table></iframe>";
	out += "<center><input type='button' value='&nbsp;&nbsp;&nbsp;&nbsp;Print&nbsp;&nbsp;&nbsp;&nbsp;' onclick='window.print();'/>";	
	document.getElementById("mainDiv").innerHTML = out;
	
	resizeImg();
	
}

function resizeImg()
{
	var div = document.getElementById("mainDiv");
	var images = div.getElementsByTagName("img");
	for(var i=0;i<images.length;i++)
	{
		var width = images[i].width;
		var height = images[i].height;
		
		if(navigator.appName == "Netscape")
		{
			if(width > 20)
				images[i].style.width = "500px";
			if(height > 20)
				images[i].style.height = "450px";
		}
		else
		{
			if(width > 500)
				images[i].style.width = "500px";
			if(height > 500)
				images[i].style.height = "450px";
		}	
		
	}
}
	
</script>
<center>
<div id="mainDiv">
<form name= "previewForm">

<center><table  class="Btable" height= "50%" width="99%" cellspacing="0" cellpadding="0" >
<tr><td style="color: #000000; font-size: 12pt" ><b>Title:</b></td>
	<td colspan="8" >
	<div id="titleDiv" style="color: #ff0000; font-size: 14pt"></div>
	</td>
</tr>
<tr>
	<td id="Description" class="choosen" onclick="show1(1,'Description')">Description
	</td>
	<td id="Project_Objectives" class="free" onclick="show1(2,'Project_Objectives')">Project<br>Objectives
	</td>
	<td id="Required_Background" class="free" onclick="show1(3,'Required_Background')">Required<br>Background
	</td>
	<td id="Tools_Needed" class="free" onclick="show1(4,'Tools_Needed')">Tools<br>Needed
	</td>
	<td id="Difficulty_Level" class="free" onclick="show1(5,'Difficulty_Level')">Difficulity<br>Level
	</td>
	<td id="Project_Type" class="free" onclick="show1(6,'Project_Type')">Project<br>Type
	</td>
	<td id="Project_Keywords" class="free" onclick="show1(7,'Project_Keywords')">Project<br>Keywords
	</td>
	<td id="Expected_Results" class="free" onclick="show1(8,'Expected_Results')">Expected<br>Results
	</td>
	<td id="Additional_Comments" class="free" onclick="show1(9,'Additional_Comments')">Additional<br>Comments
	</td>
</tr>	
<tr height="100%"  style="padding: 0px; width: 90%; height: 500">
	<td  class="tabsbody" colspan="10" valign="top">
	<div id="preview">
	</div>
	</td>
</tr>
<tr>
	<td colspan="9">
		<center><input type="button" value ="&nbsp;&nbsp;Display for print&nbsp;&nbsp;" onclick="printProject()"/></center>
	</td>
</tr>
	 </table>
</form>
</div>
</center>


</body>
</html>